#ifndef CAMERA_H_
#define CAMERA_H_

/************************************************************************/
/*  Simple Camera Class: By Callum Brighting                            */
/************************************************************************/

#include "Vec3.h"
#include "Frustum.h"
#include <d3dx9.h>

class Camera
{
public:
    /* default Ctr */
    Camera();
    virtual ~Camera() {}
    /* Called once per frame */
    void Prepare();
    void Update();
    /* Creates a projection matrix based on its member variables, call if you change them */
    void CreateProjectionMatrix();

    /* Get functions */
    const D3DXMATRIXA16& GetViewMatrix()       const   { return m_viewMatrix; }    
    const D3DXMATRIXA16& GetProjectionMatrix() const   { return m_projectionMatrix; }
    const Frustum& GetFrustum() const {return m_frustum;}

    /* Set Functions */
    void SetProjection(float nearClip, float farClip, float ratio, float fieldOfView);
    void SetPosition(const Vec3& other);
    void SetDirection(const Vec3& other);
    void SetUpVector(const Vec3& other);

    void Reset();

    float GetNear();
    float GetFar();

    const Vec3& GetPos() const {return m_pos;}
    const Vec3& GetDir() const {return m_dir;}

protected:

    /* for creation of the view matrix */
    Vec3 m_pos;
    Vec3 m_dir;
    Vec3 m_up;

    /* for creation of the projection matrix*/
    float m_nearClip;
    float m_farClip;
    float m_aspectRatio;
    float m_fieldOfView;

    /*Rendering matrices */
    D3DXMATRIXA16 m_viewMatrix;
    D3DXMATRIXA16 m_projectionMatrix;

    /* Frustum culling */
    Frustum m_frustum;
};


#endif